package com.codeye.spider;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

public class Queue {
	private static LinkedList<String> errQueue = new LinkedList<String>();
	private static Map<String,String> resultQueue = new HashMap<String,String>();
	
	public synchronized static void addElemErr(String url) {
		errQueue.add(url);
	}
	public static LinkedList<String> getErrQueue() {
		return errQueue;
	}
	public synchronized static void addElem(Map<String,String> rmap) {
		resultQueue.putAll(rmap);
	}
	public static int size_resultmap() {
		return resultQueue.size();
	}
	public static int size_err() {
		return errQueue.size();
	}
	public static Map<String,String> getRmap() {
		return resultQueue;
	}
	
	
	/** 超链接队列 */
	private static LinkedList<String> urlQueue = new LinkedList<String>();

	/** 队列中对应最多的超链接数量 */
	public static final int MAX_SIZE = 10000;

	public synchronized static void addElem(String url) {
		urlQueue.add(url);
	}

	public synchronized static String getAndRemoveFirstElem() {
		return urlQueue.removeFirst();
	}

	public synchronized static boolean isEmpty() {
		return urlQueue.isEmpty();
	}

	public static int size() {
		return urlQueue.size();
	}

	public static boolean isContains(String url) {
		return urlQueue.contains(url);
	}

}
